package com.demo.controller;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
 
public class GifConverter {
    public static void convertGif(String inputPath, String outputPath) throws IOException {
        // 读取图片
        BufferedImage image = ImageIO.read(new File(inputPath));
        
        // 写入图片
        ImageIO.write(image, "GIF", new File(outputPath));
    }
 
    public static void main(String[] args) {
        try {
            convertGif("/Users/wangfengchen/Downloads/test/img.gif", "/Users/wangfengchen/Downloads/test/success.gif");
            System.out.println("GIF conversion successful.");
        } catch (IOException e) {
            System.out.println("Error during GIF conversion.");
            e.printStackTrace();
        }
    }
}